﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BotvaBot.Configuration;
using HttpRequester.RequestMakers.Base;
using System.Net;
using HttpRequester;
using System.Web;
using System.IO;
using System.Text.RegularExpressions;
using mshtml;
using Helpers;
using Helpers.Extensions;
using BotvaBot.RequestChains;
using BotvaBot.Configuration.Personaj;
using System.Threading;
using BotvaBot.RequestChainItems.Base;
using System.Reflection;
using HAP = HtmlAgilityPack;
using Common.Constants;
using HtmlParsing;
using BotvaBot.RequestChainItems;
using BotvaBot.Processor;
using System.Linq.Expressions;
using BotvaBot.RequestChains.Base;

namespace BotvaBot
{
    public partial class NewMainForm : Form
    {
        public NewMainForm()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            tcPersonajes.TabPages.Clear();
            Config.Custom.PersonajSet.Items.ForEach(personaj =>
            {
                TabPage tp = new TabPage();
                tp.Text = personaj.Name;
                UcPersonajCommands pc = new UcPersonajCommands();
                pc.Personaj = personaj;
                tp.Controls.Add(pc);
                pc.Dock = DockStyle.Fill;
                tcPersonajes.TabPages.Add(tp);
            });
        }

        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);
        }

        #region Hidden

        private void MainForm_Load(object sender, EventArgs e)
        {
            Hide();
            notifyIcon.Visible = true;
            WindowState = FormWindowState.Minimized;
        }

        private void MainForm_Resize(object sender, EventArgs e)
        {
            if (WindowState == FormWindowState.Minimized)
            {
                notifyIcon.Visible = true;
                Hide();
            }
        }

        private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            notifyIcon.Visible = false;
            Show();
            WindowState = FormWindowState.Normal;
        }

        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            notifyIcon.Visible = false;
        }

        #endregion Hidden

        private void btnShowCommadsTestingForm_Click(object sender, EventArgs e)
        {
            TestCommandsForm frm = new TestCommandsForm();
            frm.ShowDialog();
        }
    }
}
